home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5416 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What does the -O option do???!!!
  5. Date: Fri, 09 Feb 96 00:50:08 GMT
  6. Organization: none
  7. Message-ID: <823827008snz@genesis.demon.co.uk>
  8. References: <4ehger$cj9@mark.ucdavis.edu> <4emlsq$odt@airdmhor.gen.nz> <pronet01.34.003B9BB5@indirect.com>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <pronet01.34.003B9BB5@indirect.com>
  15.            pronet01@indirect.com "Mark Miller" writes:
  16.  
  17. >Hint:  When you're done using a pointer (and it has not gone out of
  18. >scope), explicitly set it to NULL..
  19.  
  20. Why? If you're done with a variable the value it contains is immaterial.
  21.  
  22. > I have seen the optimized version
  23. >move addresses for a pointer variable that you have used "free" on..
  24.  
  25. As far as the C language is concerned the value of a pointer is
  26. indeterminate if the object it pointed to has been freed. Therefore code
  27. that tries to use the value of a pointer after that has been passed to
  28. free is plain broken (except possibly, as has been argued on comp.stc.c,
  29. if that value is accessed as a char array). So if a compiler can generate
  30. more efficient code my making use of this then that is a good compiler and
  31. all correct programs will continue to work with it.
  32.  
  33. -- 
  34. -----------------------------------------
  35. Lawrence Kirby | fred@genesis.demon.co.uk
  36. Wilts, England | 70734.126@compuserve.com
  37. -----------------------------------------
  38.